(0) Obligation:

The Runtime Complexity (innermost) of the given CpxTRS could be proven to be BOUNDS(1, n^2).


The TRS R consists of the following rules:

lt(0, s(x)) → true
lt(x, 0) → false
lt(s(x), s(y)) → lt(x, y)
minus(x, y) → help(lt(y, x), x, y)
help(true, x, y) → s(minus(x, s(y)))
help(false, x, y) → 0

Rewrite Strategy: INNERMOST

(1) TrsToWeightedTrsProof (BOTH BOUNDS(ID, ID) transformation)

Transformed TRS to weighted TRS

(2) Obligation:

The Runtime Complexity (innermost) of the given CpxWeightedTrs could be proven to be BOUNDS(1, n^2).


The TRS R consists of the following rules:

lt(0, s(x)) → true [1]
lt(x, 0) → false [1]
lt(s(x), s(y)) → lt(x, y) [1]
minus(x, y) → help(lt(y, x), x, y) [1]
help(true, x, y) → s(minus(x, s(y))) [1]
help(false, x, y) → 0 [1]

Rewrite Strategy: INNERMOST

(3) TypeInferenceProof (BOTH BOUNDS(ID, ID) transformation)

Infered types.

(4) Obligation:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

lt(0, s(x)) → true [1]
lt(x, 0) → false [1]
lt(s(x), s(y)) → lt(x, y) [1]
minus(x, y) → help(lt(y, x), x, y) [1]
help(true, x, y) → s(minus(x, s(y))) [1]
help(false, x, y) → 0 [1]

The TRS has the following type information:
lt :: 0:s → 0:s → true:false
0 :: 0:s
s :: 0:s → 0:s
true :: true:false
false :: true:false
minus :: 0:s → 0:s → 0:s
help :: true:false → 0:s → 0:s → 0:s

Rewrite Strategy: INNERMOST

(5) CompletionProof (UPPER BOUND(ID) transformation)

The TRS is a completely defined constructor system, as every type has a constant constructor and the following rules were added:
none

And the following fresh constants: none

(6) Obligation:

Runtime Complexity Weighted TRS where all functions are completely defined. The underlying TRS is:

Runtime Complexity Weighted TRS with Types.
The TRS R consists of the following rules:

lt(0, s(x)) → true [1]
lt(x, 0) → false [1]
lt(s(x), s(y)) → lt(x, y) [1]
minus(x, y) → help(lt(y, x), x, y) [1]
help(true, x, y) → s(minus(x, s(y))) [1]
help(false, x, y) → 0 [1]

The TRS has the following type information:
lt :: 0:s → 0:s → true:false
0 :: 0:s
s :: 0:s → 0:s
true :: true:false
false :: true:false
minus :: 0:s → 0:s → 0:s
help :: true:false → 0:s → 0:s → 0:s

Rewrite Strategy: INNERMOST

(7) CpxTypedWeightedTrsToRntsProof (UPPER BOUND(ID) transformation)

Transformed the TRS into an over-approximating RNTS by (improved) Size Abstraction.
The constant constructors are abstracted as follows:

0 => 0
true => 1
false => 0

(8) Obligation:

Complexity RNTS consisting of the following rules:

help(z, z', z'') -{ 1 }→ 0 :|: z' = x, z'' = y, x >= 0, y >= 0, z = 0
help(z, z', z'') -{ 1 }→ 1 + minus(x, 1 + y) :|: z' = x, z'' = y, z = 1, x >= 0, y >= 0
lt(z, z') -{ 1 }→ lt(x, y) :|: z' = 1 + y, x >= 0, y >= 0, z = 1 + x
lt(z, z') -{ 1 }→ 1 :|: z' = 1 + x, x >= 0, z = 0
lt(z, z') -{ 1 }→ 0 :|: x >= 0, z = x, z' = 0
minus(z, z') -{ 1 }→ help(lt(y, x), x, y) :|: x >= 0, y >= 0, z = x, z' = y

Only complete derivations are relevant for the runtime complexity.

(9) CompleteCoflocoProof (EQUIVALENT transformation)

Transformed the RNTS (where only complete derivations are relevant) into cost relations for CoFloCo:

eq(start(V, V1, V8),0,[lt(V, V1, Out)],[V >= 0,V1 >= 0]).
eq(start(V, V1, V8),0,[minus(V, V1, Out)],[V >= 0,V1 >= 0]).
eq(start(V, V1, V8),0,[help(V, V1, V8, Out)],[V >= 0,V1 >= 0,V8 >= 0]).
eq(lt(V, V1, Out),1,[],[Out = 1,V1 = 1 + V2,V2 >= 0,V = 0]).
eq(lt(V, V1, Out),1,[],[Out = 0,V3 >= 0,V = V3,V1 = 0]).
eq(lt(V, V1, Out),1,[lt(V4, V5, Ret)],[Out = Ret,V1 = 1 + V5,V4 >= 0,V5 >= 0,V = 1 + V4]).
eq(minus(V, V1, Out),1,[lt(V6, V7, Ret0),help(Ret0, V7, V6, Ret1)],[Out = Ret1,V7 >= 0,V6 >= 0,V = V7,V1 = V6]).
eq(help(V, V1, V8, Out),1,[minus(V9, 1 + V10, Ret11)],[Out = 1 + Ret11,V1 = V9,V8 = V10,V = 1,V9 >= 0,V10 >= 0]).
eq(help(V, V1, V8, Out),1,[],[Out = 0,V1 = V11,V8 = V12,V11 >= 0,V12 >= 0,V = 0]).
input_output_vars(lt(V,V1,Out),[V,V1],[Out]).
input_output_vars(minus(V,V1,Out),[V,V1],[Out]).
input_output_vars(help(V,V1,V8,Out),[V,V1,V8],[Out]).

CoFloCo proof output:
Preprocessing Cost Relations
=====================================

#### Computed strongly connected components
0. recursive : [lt/3]
1. recursive : [help/4,minus/3]
2. non_recursive : [start/3]

#### Obtained direct recursion through partial evaluation
0. SCC is partially evaluated into lt/3
1. SCC is partially evaluated into minus/3
2. SCC is partially evaluated into start/3

Control-Flow Refinement of Cost Relations
=====================================

### Specialization of cost equations lt/3
* CE 10 is refined into CE [11]
* CE 9 is refined into CE [12]
* CE 8 is refined into CE [13]


### Cost equations --> "Loop" of lt/3
* CEs [12] --> Loop 8
* CEs [13] --> Loop 9
* CEs [11] --> Loop 10

### Ranking functions of CR lt(V,V1,Out)
* RF of phase [10]: [V,V1]

#### Partial ranking functions of CR lt(V,V1,Out)
* Partial RF of phase [10]:
- RF of loop [10:1]:
V
V1


### Specialization of cost equations minus/3
* CE 7 is refined into CE [14,15]
* CE 6 is refined into CE [16,17]


### Cost equations --> "Loop" of minus/3
* CEs [17] --> Loop 11
* CEs [16] --> Loop 12
* CEs [15] --> Loop 13
* CEs [14] --> Loop 14

### Ranking functions of CR minus(V,V1,Out)
* RF of phase [13]: [V-V1]

#### Partial ranking functions of CR minus(V,V1,Out)
* Partial RF of phase [13]:
- RF of loop [13:1]:
V-V1


### Specialization of cost equations start/3
* CE 3 is refined into CE [18,19,20]
* CE 2 is refined into CE [21]
* CE 4 is refined into CE [22,23,24,25]
* CE 5 is refined into CE [26,27,28,29,30]


### Cost equations --> "Loop" of start/3
* CEs [24,30] --> Loop 15
* CEs [20] --> Loop 16
* CEs [19,25,29] --> Loop 17
* CEs [18,23,27,28] --> Loop 18
* CEs [21,22,26] --> Loop 19

### Ranking functions of CR start(V,V1,V8)

#### Partial ranking functions of CR start(V,V1,V8)


Computing Bounds
=====================================

#### Cost of chains of lt(V,V1,Out):
* Chain [[10],9]: 1*it(10)+1
Such that:it(10) =< V

with precondition: [Out=1,V>=1,V1>=V+1]

* Chain [[10],8]: 1*it(10)+1
Such that:it(10) =< V1

with precondition: [Out=0,V1>=1,V>=V1]

* Chain [9]: 1
with precondition: [V=0,Out=1,V1>=1]

* Chain [8]: 1
with precondition: [V1=0,Out=0,V>=0]


#### Cost of chains of minus(V,V1,Out):
* Chain [[13],11]: 3*it(13)+1*s(1)+1*s(4)+3
Such that:it(13) =< Out
aux(2) =< V1+Out
s(1) =< aux(2)
s(4) =< it(13)*aux(2)

with precondition: [V=Out+V1,V1>=1,V>=V1+1]

* Chain [14,[13],11]: 4*it(13)+1*s(4)+6
Such that:aux(3) =< Out
it(13) =< aux(3)
s(4) =< it(13)*aux(3)

with precondition: [V1=0,V=Out,V>=2]

* Chain [14,11]: 1*s(1)+6
Such that:s(1) =< 1

with precondition: [V=1,V1=0,Out=1]

* Chain [12]: 3
with precondition: [V=0,Out=0,V1>=0]

* Chain [11]: 1*s(1)+3
Such that:s(1) =< V

with precondition: [Out=0,V>=1,V1>=V]


#### Cost of chains of start(V,V1,V8):
* Chain [19]: 3
with precondition: [V=0,V1>=0]

* Chain [18]: 1*s(5)+4*s(7)+1*s(8)+6
Such that:s(5) =< 1
s(6) =< V
s(7) =< s(6)
s(8) =< s(7)*s(6)

with precondition: [V1=0,V>=0]

* Chain [17]: 1*s(9)+2*s(10)+4
Such that:s(9) =< V1
aux(4) =< V
s(10) =< aux(4)

with precondition: [V>=1,V1>=V]

* Chain [16]: 3*s(12)+1*s(14)+1*s(15)+4
Such that:s(13) =< V1
s(12) =< V1-V8
s(14) =< s(13)
s(15) =< s(12)*s(13)

with precondition: [V=1,V8>=0,V1>=V8+2]

* Chain [15]: 1*s(16)+3*s(17)+1*s(19)+1*s(20)+3
Such that:s(18) =< V
s(17) =< V-V1
s(16) =< V1
s(19) =< s(18)
s(20) =< s(17)*s(18)

with precondition: [V1>=1,V>=V1]


Closed-form bounds of start(V,V1,V8):
-------------------------------------
* Chain [19] with precondition: [V=0,V1>=0]
- Upper bound: 3
- Complexity: constant
* Chain [18] with precondition: [V1=0,V>=0]
- Upper bound: 4*V+7+V*V
- Complexity: n^2
* Chain [17] with precondition: [V>=1,V1>=V]
- Upper bound: 2*V+V1+4
- Complexity: n
* Chain [16] with precondition: [V=1,V8>=0,V1>=V8+2]
- Upper bound: 3*V1-3*V8+ (V1+4+ (V1-V8)*V1)
- Complexity: n^2
* Chain [15] with precondition: [V1>=1,V>=V1]
- Upper bound: 3*V-3*V1+ (V+3+ (V-V1)*V+V1)
- Complexity: n^2

### Maximum cost of start(V,V1,V8): max([max([V+1+max([V1,2*V+3+V*V]),nat(V-V1)*V+V1+nat(V-V1)*3])+V,V1+1+nat(V1-V8)*V1+nat(V1-V8)*3])+3
Asymptotic class: n^2
* Total analysis performed in 202 ms.

(10) BOUNDS(1, n^2)